If -o is not specified, the default is to put an executable file in a.out, the object file source.c in source.o, an assembler file in source.s, and preprocessed C on standard output.
For each subprogram to be run, the compiler driver first tries the -B prefix, if any. If that name is not found, or if -B was not specified, the driver tries two standard prefixes, which are /usr/lib/gcc- and /usr/local/lib/gcc-. If neither of those results in a file name that is found, the unmodified program name is searched for using the directories specified in your PATH environment variable.
The run-time support file gnulib is also searched for using the -B prefix, if needed. If it is not found there, the two standard prefixes above are tried, and that is all. The file is left out of the link if it is not found by those means. Most of the time, on most machines, you can do without it.
You can get a similar result from the environment variable GCC_EXEC_PREFIX; if it is defined, its value is used as a prefix in the same way. If both the -B option and the GCC_EXEC_PREFIX variable are present, the -B option is used first and the environment variable value second.
Thus, -bvax- -Bcc/ in the presence of environment variable GCC_EXEC_PREFIX with definition /u/foo/ causes GNU CC to try the following file names for the preprocessor executable:
cc/vax-cpp
cc/cpp
/u/foo/vax-cpp
/u/foo/cpp
/usr/local/lib/gcc-vax-cpp
/usr/local/lib/gcc-cpp
/usr/lib/gcc-vax-cpp
/usr/lib/gcc-cpp
These options control the details of C compilation itself.
This turns off certain features of GNU C that are incompatible with ANSI C, such as the asm, inline and typeof keywords, and predefined macros such as unix and vax that identify the type of system you are using. It also enables the undesirable and rarely used ANSI trigraph feature.
The alternate keywords __asm__, __inline__ and __typeof__ continue to work despite -ansi. You would not want to use them in an ANSI C program, of course, but it useful to put them in header files that might be included in compilations done with -ansi. Alternate predefined macros such as __unix__ and __vax__ are also available, with or without -ansi.
The -ansi option does not cause non-ANSI programs to be rejected gratuitously. For that, -pedantic is required in addition to -ansi.
The macro __STRICT_ANSI__ is predefined when the -ansi option is used. Some header files may notice this macro and refrain from declaring certain functions or defining certain macros that the ANSI standard doesn't call for; this is to avoid interfering with any programs that might use these names for other things.
*
All
extern
declarations take effect globally even if they are
written inside of a function definition.
This includes implicit declarations of functions.
*
The keywords
typeof,
inline,
signed,
const
and
volatile
are not recognized.
*
Comparisons between pointers and integers are always allowed.
*
Integer types
unsigned short
and
unsigned char
promote to
unsigned int.
*
Out-of-range floating point literals are not an error.
*
All automatic variables not declared
register
are preserved by
longjmp(3C).
Ordinarily, GNU C follows ANSI C: automatic variables not declared
volatile
may be clobbered.
*
In the preprocessor, comments convert to nothing at all,
rather than to a space.
This allows traditional token concatenation.
*
In the preprocessor, macro arguments are recognized within string
constants in a macro definition (and their values are stringified, though
without additional quote marks, when they appear in such a context).
The preprocessor always considers a string constant to end at a newline.
*
The predefined macro
__STDC__
is not defined when you use
-traditional,
but
__GNUC__
is (since the GNU extensions which
__GNUC__
indicates are not affected by
-traditional).
If you need to write header files that work differently depending on whether
-traditional
is in use, by testing both of these predefined macros you can distinguish
four situations: GNU C, traditional GNU C, other ANSI C compilers, and
other old C compilers.
Without -O, the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.
Without -O, only variables declared register are allocated in registers. The resulting compiled code is a little worse than produced by PCC without -O.
With -O, the compiler tries to reduce code size and execution time.
Some of the -f options described below turn specific kinds of optimization on or off.
Unlike most other C compilers, GNU CC allows you to use -g with -O. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops. Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.
This feature will probably be eliminated. It was intended to enable GDB to read the symbol table faster, but it doesn't result in enough of a speedup to be worth the larger object files and executables. We are working on other ways of making GDB start even faster, which work with DBX format debugging information and could be made to work with SDB format.
*
An automatic variable is used without first being initialized.
These warnings are possible only in optimizing compilation, because they require data flow information that is computed only when optimizing. If you don't specify -O, you simply won't get these warnings.
These warnings occur only for variables that are candidates for register allocation. Therefore, they do not occur for a variable that is declared volatile, or whose address is taken, or whose size is other than 1, 2, 4 or 8 bytes. Also, they do not occur for structures, unions or arrays, even when they are in registers.
Note that there may be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data flow analysis before the warnings are printed.
These warnings are made optional because GNU CC is not smart enough to see all the reasons why the code might be correct despite appearing to have an error. Here is one example of how this can happen:
{
int x;
switch (y)
{
case 1: x = 1;
break;
case 2: x = 4;
break;
case 3: x = 5;
}
foo (x);
}
If the value of y is always 1, 2 or 3, then x is always initialized, but GNU CC doesn't know this. Here is another common case:
{
int save_y;
if (change_y) save_y = y, y = new_y;
...
if (change_y) y = save_y;
}
This has no bug because save_y is used only if it is set.
Some spurious warnings can be avoided if you declare as volatile all the functions you use that never return.
*
A nonvolatile automatic variable might be changed by a call to
longjmp(3C).
These warnings as well are possible only in optimizing compilation.
The compiler sees only the calls to setjmp(3C). It cannot know where longjmp(3C) will be called; in fact, a signal handler could call it at any point in the code. As a result, you may get a warning even when there is in fact no problem because longjmp(3C) cannot in fact be called at the place which would cause a problem.
*
A function can return either with or without a value.
(Falling off the end of the function body is considered returning without
a value.)
For example, this function would evoke such a warning:
foo (a)
{
if (a > 0)
return a;
}
Spurious warnings can occur because GNU CC does not realize that certain functions (including abort(3C) and longjmp(3C)) will never return.
*
An expression-statement contains no side effects.
In the future, other useful warnings may also be enabled by this option.
The other -W... options below are not implied by -Wall because certain kinds of useful macros are almost impossible to write without causing those warnings.
The directories searched include several standard system directories plus any that you specify with -L.
Normally the files found this way are library files--archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l searches several directories.
These are the -m options defined in the 68000 machine description:
-m68020
-mc68020
Generate output for a 68020 (rather than a 68000).
This is the default if you use the unmodified sources.
-m68000
-mc68000
Generate output for a 68000 (rather than a 68020).
-m68881 Generate output containing 68881 instructions for floating point. This is the default if you use the unmodified sources.
-mfpa Generate output containing Sun FPA instructions for floating point.
-msoft-float Generate output containing library calls for floating point.
-mshort Consider type int to be 16 bits wide, like short int.
-mnobitfield Do not use the bit-field instructions. -m68000 implies -mnobitfield.
-mbitfield Do use the bit-field instructions. -m68020 implies -mbitfield. This is the default if you use the unmodified sources.
-mrtd Use a different function-calling convention, in which functions that take a fixed number of arguments return with the rtd instruction, which pops their arguments while returning. This saves one instruction in the caller since there is no need to pop the arguments there.
This calling convention is incompatible with the one normally used on Unix, so you cannot use it if you need to call libraries compiled with the Unix compiler.
Also, you must provide function prototypes for all functions that take variable numbers of arguments (including printf(3S)); otherwise incorrect code will be generated for calls to those functions.
In addition, seriously incorrect code will result if you call a function with too many arguments. (Normally, extra arguments are harmlessly ignored.)
The rtd instruction is supported by the 68010 and 68020 processors, but not by the 68000.
These -m options are defined in the Vax machine description:
-munix Do not output certain jump instructions (aobleq and so on) that the Unix assembler for the Vax cannot handle across long ranges.
-mgnu Do output those jump instructions, on the assumption that you will assemble with the GNU assembler.
-mg Output code for g-format floating point numbers instead of d-format.
These -m switches are supported on the Sparc:
-mfpu Generate output containing floating point instructions. This is the default if you use the unmodified sources.
-msoft-float Generate output containing library calls for floating point.
-mno-epilogue Generate separate return instructions for return statements. This has both advantages and disadvantages; I don't recall what they are.
These -m options are defined in the Convex machine description:
-mc1 Generate output for a C1. This is the default when the compiler is configured for a C1.
-mc2 Generate output for a C2. This is the default when the compiler is configured for a C2.
-margcount Generate code which puts an argument count in the word preceding each argument list. Some nonportable Convex and Vax programs need this word. (Debuggers don't; this info is in the symbol table.)
-mnoargcount Omit the argument count word. This is the default if you use the unmodified sources.
For most programs, the excess precision does only good, but a few programs rely on the precise definition of IEEE floating point. Use -ffloat-store for such programs.
On some machines, such as the Vax, this flag has no effect, because the standard calling sequence automatically handles the frame pointer and nothing is saved by pretending it doesn't exist. The machine-description macro FRAME_POINTER_REQUIRED controls whether a target machine supports this flag.
If all calls to a given function are integrated, and the function is declared static, then the function is normally not output as assembler code in its own right.
This option is enabled by default on certain machines, usually those which have no call-preserved registers to use instead.
This option results in less efficient code, but some strange hacks that alter the assembler output may be confused by the optimizations performed when this option is not used.
Each kind of machine has a default for what char should be. It is either like unsigned char by default or like signed char by default. (Actually, at present, the default is always signed.)
The type char is always a distinct type from either signed char or unsigned char, even though its behavior is always just like one of those two.
Note that this is equivalent to -fno-signed-char, which is the negative form of -fsigned-char.
Note that this is equivalent to -fno-unsigned-char, which is the negative form of -funsigned-char.
reg must be the name of a register. The register names accepted are machine-specific and are defined in the REGISTER_NAMES macro in the machine description macro file.
This flag does not have a negative form, because it specifies a three-way choice.
Use of this flag for a register that has a fixed pervasive role in the machine's execution model, such as the stack pointer or frame pointer, will produce disastrous results.
This flag does not have a negative form, because it specifies a three-way choice.
Use of this flag for a register that has a fixed pervasive role in the machine's execution model, such as the stack pointer or frame pointer, will produce disastrous results.
A different sort of disaster will result from the use of this flag for a register in which function values may be returned.
This flag does not have a negative form, because it specifies a three-way choice.
r Dump after RTL generation. j Dump after first jump optimization. J Dump after last jump optimization. s Dump after CSE (including the jump optimization that sometimes follows CSE). L Dump after loop optimization. f Dump after flow analysis. c Dump after instruction combination. l Dump after local register allocation. g Dump after global register allocation. d Dump after delayed branch scheduling. m Print statistics on memory usage, at the end of the run.
Valid ANSI standard C programs should compile properly with or without this option (though a rare few will require -ansi). However, without this option, certain GNU extensions and traditional C features are supported as well. With this option, they are rejected. There is no reason to use this option; it exists only to satisfy pedants.
-pedantic does not cause warning messages for use of the alternate keywords whose names begin and end with __.
If additional directories are specified with -I options after the -I-, these directories are searched for all #include directives. (Ordinarily all -I directories are used this way.)
In addition, the -I- option inhibits the use of the current directory as the first search directory for #include "file". Therefore, the current directory is searched only if it is requested explicitly with -I.. Specifying both -I- and -I. allows you to control precisely which directories are searched before the current one and which are searched after.
Between -nostdinc and -I-, you can eliminate all directories from the search path except those you specify.
-M implies -E.
-MM implies -E.
LIBDIR is usually /usr/local/lib.